<?php
require("../../DBops.php");
session_start();

$havedonevalue = $_POST['havedonevalue'];
$notyetvalue = $_POST['notyetvalue'];
$plan = $_POST['plan'];

$con = connect("localhost", "root", "", "lab");
//echo $_SESSION['user'];
if(isset($_SESSION['user']))
{
	
	$result = query($con, "*", "personalinfo", "ID", $_SESSION['user']);
	$row = mysql_fetch_array($result);
	date_default_timezone_set ('PRC');
	
	$data = array($_SESSION['user'], $row['name'], $havedonevalue, $notyetvalue, $plan, date('Y-m-d H:i:s',time()),$row['projecteamID']);
	
	if($_GET['type'] == 'edit')
	{
		$sql = "delete from weeklyreport where datetime = (select datetime from (select * from weeklyreport where ID = '".$_SESSION['user']."') a order by datetime desc limit 1)";
		mysql_query($sql, $con);
	}
	
	insertIntoDB($con, "weeklyreport", $data);
	echo "<script>location.href='Report.php?id=".$_SESSION['user']."';</script>"; 
}

